package portal.monitor.dao.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import portal.monitor.dao.MonitorSoftware;
import portal.monitor.dao.mapper.MonitorSoftwareMapper;

import java.util.List;

@Service
public class MonitorSoftwareService {
    @Autowired
    MonitorSoftwareMapper monitorSoftwareMapper;


    public Integer insert(MonitorSoftware monitorSoftware){
        return monitorSoftwareMapper.insert(monitorSoftware);
    }

    public Integer deleteByPrimaryKey(int softwareId){
        return monitorSoftwareMapper.deleteByPrimaryKey(softwareId);
    }

    public Integer updateByPrimaryKey(MonitorSoftware monitorSoftware){
        return monitorSoftwareMapper.updateByPrimaryKey(monitorSoftware);
    }

    public MonitorSoftware selectByPrimaryKey(int softwareId){
        return monitorSoftwareMapper.selectByPrimaryKey(softwareId);
    }

    public List<MonitorSoftware> selectAll(){
        return monitorSoftwareMapper.selectAll();
    }

    public List<MonitorSoftware> selectByPage(int currentPage, int onePageCount){
        if(onePageCount<1||currentPage<1) return  null;
        int currentPosition = (currentPage-1)*onePageCount;
        return monitorSoftwareMapper.selectByPage(currentPosition, onePageCount);
    }

    public Integer pageNum(Integer onePageCount){
        if(onePageCount<1) return -1;
        int softwareNum = monitorSoftwareMapper.softwareNum();
        return (softwareNum%onePageCount==0)?(softwareNum/onePageCount):(softwareNum/onePageCount+1);
    }

    public List<MonitorSoftware> selectByPrimaryKeys(Integer[] softwareIds){
        return monitorSoftwareMapper.selectByPrimaryKeys(softwareIds);
    }

}
